image: gradle:6.4.0-jdk11
stages:
  - build
  - test  
  - deploy
variables:
  GRADLE_OPTS: "-Dorg.gradle.daemon=false"

before_script:
  - export GRADLE_USER_HOME=`pwd`/.gradle

buildClient:
  stage: build
  script:
      - |
          echo "Start the build of Client"
          gradle :Client:build
  cache:
    key: "$CI_COMMIT_REF_NAME"
    policy: push
    paths:
      - build
      - .gradle
  artifacts:
    paths:
      - build/libs/*.jar
    expire_in: 1 week

buildServer:
    stage: build
    script:
        - |
            echo "Start the build of Server"
            cd Server
            gradle --build-cache assemble
    artifacts:
      paths:
        - build/libs/*.jar
      expire_in: 1 week
testServer:
  stage: test
  script:
    - |
      echo "Start the test of Server"
      cd Server
      gradle --build-cache check

#testRunServer:
#  stage: test
#  script:
#    - |
#      echo "Start the test of Server"
#      cd h2-crud-json
#      gradle --build-cache bootRun

compile_pdf:
  stage: build
  image: timnn/texlive  # use a Docker image for LaTeX from https://hub.docker.com/
  script:
    - cd docs/Architekturbeschreibung/
    - pdflatex Architekturbeschreibung.tex   # build the pdf just as you would on your computer
  artifacts:
    paths:
      - docs/Architekturbeschreibung/Architekturbeschreibung.pdf  # instruct GitLab to keep the main.pdf file

pages:
  stage: deploy
  script:
    - mkdir public  # create a folder called public
    - cp docs/Architekturbeschreibung/Architekturbeschreibung.pdf public/Architekturbeschreibung.pdf # copy the pdf file into the public folder
  artifacts:
    paths:
      - public  # instruct GitLab to keep the public folder
  only:
    - master  # deploy the pdf only for commits made to the master branch

include:
  - template: Dependency-Scanning.gitlab-ci.yml
